home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 23 / AMIGAplus Sonderheft 23 (2000)(Falke)(DE)[!].iso / Updates / HD-Installer / -WHDLoad- / WHDLoad_dev / Src / imager-examples / ik+.imager.asm < prev    next >
Assembly Source File  |  1999-11-08  |  7KB  |  338 lines

  1. ;*---------------------------------------------------------------------------
  2. ;  :Program.    ik+.imager.asm
  3. ;  :Contents.    Imager for IK+
  4. ;  :Author.    WEPL
  5. ;  :Version.    $Id: ik+.imager.asm 1.2 1998/06/27 23:48:35 jah Exp jah $
  6. ;  :History.    18.09.97 first try
  7. ;  :Requires.    -
  8. ;  :Copyright.    Public Domain
  9. ;  :Language.    68000 Assembler
  10. ;  :Translator.    Barfly V1.131
  11. ;  :To Do.
  12. ;---------------------------------------------------------------------------*
  13.  
  14.     INCDIR    Includes:
  15.     INCLUDE    devices/trackdisk.i
  16.     INCLUDE    utility/tagitem.i
  17.     INCLUDE    lvo/exec.i
  18.     INCLUDE    patcher.i
  19.  
  20.     IFD BARFLY
  21.     OUTPUT    "C:Parameter/ik+.imager"
  22.     BOPT    O+ OG+            ;enable optimizing
  23.     BOPT    ODd- ODe-        ;disable mul optimizing
  24.     ENDC
  25.  
  26. ;======================================================================
  27.  
  28.         moveq    #-1,d0
  29.         rts
  30.         dc.l    _Table
  31.         dc.l    "PTCH"
  32.  
  33. ;======================================================================
  34.  
  35. _Table        dc.l    PCH_ADAPTOR,.adname        ;name adaptor
  36.         dc.l    PCH_NAME,.name            ;description of parameter
  37.         dc.l    PCH_FILECOUNT,1            ;number of cycles
  38.         dc.l    PCH_FILENAME,.filenamearray    ;file names
  39.         dc.l    PCH_DATALENGTH,_lengtharray    ;file lengths
  40.         dc.l    PCH_DISKNAME,.disknamearray    ;disk names
  41.         dc.l    PCH_SPECIAL,.specialarray    ;functions
  42.         dc.l    PCH_STATE,.statearray        ;state texts
  43.         dc.l    PCH_MINVERSION,.patcherver    ;minimum patcher version required
  44.         dc.l    PCH_INIT,_Init            ;init routine
  45.         dc.l    PCH_FINISH,_Finish        ;finish routine
  46.         dc.l    TAG_DONE
  47.  
  48. .filenamearray    dc.l    .f1
  49. .disknamearray    dc.l    .d1
  50. .specialarray    dc.l    _Special
  51. .statearray    dc.l    .insertdisk
  52.  
  53. .f1        dc.b    "IK+.Image",0
  54. .d1        dc.b    "IK+",0
  55.  
  56. .adname        dc.b    "Done by Wepl.",0
  57. .name        dc.b    "IK+, Diskimager for HD-Install",0
  58. .patcherver    dc.b    "V1.04"
  59. .insertdisk    dc.b    'Please insert your original writepro-',10
  60.         dc.b    'tected disk in the source drive.',0
  61.     IFD BARFLY
  62.         dc.b    "$VER: "
  63.     DOSCMD    "WDate >T:date"
  64.     INCBIN    "T:date"
  65.         dc.b    0
  66.     ENDC
  67.     EVEN
  68.  
  69. ;======================================================================
  70.  
  71. _Init        bsr    _InitTable
  72.  
  73.         moveq    #0,d0                ;source drive
  74.         move.l    PTB_INHIBITDRIVE(a5),a0        ;inhibit drive
  75.         jsr    (a0)
  76.         tst.l    d0
  77.         bne    .error
  78.         
  79.         moveq    #0,d0                ;source drive
  80.         move.l    PTB_OPENDEVICE(a5),a0        ;open source device
  81.         jsr    (a0)
  82.         tst.l    d0
  83.         bne    .error
  84.         rts
  85.  
  86. .error        bsr    _Finish
  87.         moveq    #-1,d0
  88.         rts
  89.  
  90. ;======================================================================
  91.  
  92. _Finish        moveq    #0,d0                ;source drive
  93.         move.l    PTB_ENABLEDRIVE(a5),a0        ;deinhibit drive
  94.         jmp    (a0)
  95.  
  96. ;======================================================================
  97.  
  98. _lengtharray    dc.l    BYTESPERTRACK*TRACKS
  99.  
  100. ;======================================================================
  101.  
  102. RAWREADLEN    = $7c00
  103. BYTESPERTRACK    = $1800
  104. SYNC        = $8944
  105. TRACKS        = $3b
  106.  
  107. _Special    moveq    #-1,d7                ;D7 = return code (default=error)
  108.  
  109.         bsr    _InsertOriginal
  110.         tst.l    d0
  111.         bne    .error
  112.         
  113.     ;check for disk in drive
  114.         move.l    (PTB_DEVICESOURCEPTR,a5),a1
  115.         move.w    #TD_CHANGESTATE,(IO_COMMAND,a1)
  116.         move.l    (4).w,a6
  117.         jsr    (_LVODoIO,a6)
  118.         tst.l    (IO_ACTUAL,a1)
  119.         bne    .error
  120.  
  121.         moveq    #2,d2                ;D2 = start/actual track
  122.         moveq    #TRACKS,d3            ;D3 = amount of tracks
  123.         move.l    (PTB_ADDRESSOFFILE,a5),a2    ;A2 = file address
  124.  
  125. .next        moveq    #5-1,d6                ;D6 = retries decoding
  126. .decretry    moveq    #5-1,d5                ;D5 = retries rawread
  127. .tdretry    move.l    (PTB_DEVICESOURCEPTR,a5),a1
  128.         move.l    (PTB_SPACE,a5),(IO_DATA,a1)    ;track is to load in ptb_space
  129.         move.l    #RAWREADLEN,(IO_LENGTH,a1)    ;double length of track to decode the index-sync-read data
  130.         move.l    d2,(IO_OFFSET,a1)
  131.         move.w    #TD_RAWREAD,(IO_COMMAND,a1)
  132.         move.b    #IOTDB_INDEXSYNC,(IO_FLAGS,a1)
  133.         move.l    (4).w,a6
  134.         jsr    (_LVODoIO,a6)
  135.         tst.l    d0
  136.         beq    .tdok
  137.         dbf    d5,.tdretry
  138.         bra    .error
  139. .tdok
  140.         move.l    (PTB_SPACE,a5),a0        ;source
  141.         move.l    a2,a1                ;destination
  142.         bsr    _Decode
  143.         tst.l    d0
  144.         beq    .decok
  145.         dbf    d6,.decretry
  146.         bra    .error
  147. .decok
  148.         add.l    #BYTESPERTRACK,a2
  149.         addq.w    #2,d2                ;only one side used !
  150.         subq.w    #1,d3
  151.         bne    .next
  152.         
  153.         moveq    #0,d7                ;return code
  154.  
  155. .end
  156.     ;switch motor off
  157.         move.l    PTB_DEVICESOURCEPTR(a5),a1
  158.         clr.l    IO_LENGTH(a1)
  159.         move.w    #TD_MOTOR,IO_COMMAND(a1)
  160.         move.l    (4).w,a6
  161.         jsr    (_LVODoIO,a6)
  162.  
  163.         move.l    d7,d0
  164.         rts
  165.  
  166. .error        bsr    _Finish
  167.         bra    .end
  168.  
  169. ;======================================================================
  170. ; IN:    A0 = raw
  171. ;    A1 = dest
  172. ; OUT:    D0 = error
  173.  
  174. GetW    MACRO
  175.         cmp.l    a0,a5
  176.         bls    .error
  177.         move.l    (a0),d0
  178.         lsr.l    d5,d0
  179.     ENDM
  180.  
  181. _Decode        movem.l    d1-a6,-(a7)
  182.         move.l    a7,a6            ;A6 = return stack
  183.         lea    (RAWREADLEN,a0),a5    ;A5 = end of raw data
  184.  
  185.         addq.l    #8,a0            ;because strange subq
  186.  
  187.     ;find sync
  188. .sync1        moveq    #16-1,d5        ;D5 = shift count
  189. .sync2        GetW
  190.         cmp.w    #SYNC,d0
  191.         beq    .sync3
  192. .sync_retry    dbf    d5,.sync2
  193.         addq.l    #2,a0
  194.         bra    .sync1
  195.  
  196. .sync3        move.l    a0,-(a7)        ;save this point for new try
  197.  
  198. .sync4        addq.l    #2,a0
  199.         GetW
  200.         cmp.w    #SYNC,d0
  201.         beq    .sync4
  202.         
  203.     ;now strange stuff from original
  204.         subq.l    #6,a0
  205.         move.l    (a0),d0
  206.         ror.l    d5,d0
  207.         move.w    #SYNC,d0
  208.         rol.l    d5,d0
  209.         move.l    d0,(a0)
  210.  
  211.         MOVEQ    #-1,D6
  212.         MOVE.B    D6,D7
  213.  
  214.         MOVEQ    #2,D1
  215.         lea    (_buf_3),a4
  216.         BSR.W    .26A
  217.  
  218.         MOVE.W    #$17FF,D1
  219.         MOVEA.L    A1,A4
  220.         BSR.W    .26A
  221.  
  222.         MOVEQ    #1,D1
  223.         lea    (_buf_3),a4
  224.         BSR.W    .26A
  225.  
  226.         OR.B    D6,D7
  227.         beq    .success
  228.  
  229.         move.l    (a7)+,a0
  230.         bra    .sync_retry        ;try again
  231.  
  232. .success    moveq    #0,d0
  233. .quit        move.l    a6,a7
  234.         movem.l    (a7)+,d1-a6
  235.         rts
  236. .error        moveq    #-1,d0
  237.         bra    .quit
  238.  
  239. .26A        LEA    .35C(PC),A2
  240.         LEA    (_buf_200),A3
  241.         MOVE.L    A3,D4
  242.         MOVEQ    #$007F,D3
  243.         MOVEQ    #0,D0
  244.  
  245. .27A        GetW
  246.         addq.l    #2,a0
  247.         ror.l    #8,d0
  248.         AND.W    D3,D0
  249.         MOVEQ    #0,D2
  250.         MOVE.B    (A2,D0.W),D2
  251.         rol.l    #8,d0
  252.         AND.W    D3,D0
  253.         LSL.B    #4,D2
  254.         OR.B    (A2,D0.W),D2
  255.         MOVE.B    D2,(A4)+
  256.         MOVEA.L    D4,A3
  257.         EOR.B    D6,D2
  258.         ADDA.W    D2,A3
  259.         MOVE.B    (A3),D6
  260.         EOR.B    D7,D6
  261.         MOVE.B    $0100(A3),D7
  262.         DBRA    D1,.27A
  263.  
  264.         RTS    
  265.  
  266. .35C        DC.L    $10001
  267.         DC.L    $2030203
  268.         DC.L    $10001
  269.         DC.L    $2030203
  270.         DC.L    $4050405
  271.         DC.L    $6070607
  272.         DC.L    $4050405
  273.         DC.L    $6070607
  274.         DC.L    $10001
  275.         DC.L    $2030203
  276.         DC.L    $10001
  277.         DC.L    $2030203
  278.         DC.L    $4050405
  279.         DC.L    $6070607
  280.         DC.L    $4050405
  281.         DC.L    $6070607
  282.         DC.L    $8090809
  283.         DC.L    $A0B0A0B
  284.         DC.L    $8090809
  285.         DC.L    $A0B0A0B
  286.         DC.L    $C0D0C0D
  287.         DC.L    $E0F0E0F
  288.         DC.L    $C0D0C0D
  289.         DC.L    $E0F0E0F
  290.         DC.L    $8090809
  291.         DC.L    $A0B0A0B
  292.         DC.L    $8090809
  293.         DC.L    $A0B0A0B
  294.         DC.L    $C0D0C0D
  295.         DC.L    $E0F0E0F
  296.         DC.L    $C0D0C0D
  297.         DC.L    $E0F0E0F
  298.  
  299. _InitTable    LEA    (_buf_200),A0
  300.         MOVEQ    #0,D7
  301. .B4        MOVEQ    #0,D6
  302.         MOVE.B    D7,D6
  303.         LSL.W    #8,D6
  304.         MOVEQ    #7,D0
  305. .BC        LSL.W    #1,D6
  306.         BCC.B    .C4
  307.         EORI.W    #$1021,D6
  308. .C4        DBRA    D0,.BC
  309.         MOVE.B    D6,$0100(A0)
  310.         LSR.W    #8,D6
  311.         MOVE.B    D6,(A0)+
  312.         ADDQ.B    #1,D7
  313.         BNE.B    .B4
  314.         rts
  315.  
  316. _buf_3        ds.b    4
  317.  
  318. ;======================================================================
  319.  
  320. _InsertOriginal    lea    (.line1),a0
  321.         lea    (.line2),a1
  322.         move.l    PTB_REQUEST(a5),-(a7)
  323.         rts
  324.  
  325. .line1        dc.b    'Please insert your original disk',0
  326. .line2        dc.b    'in the source drive.',0
  327.  
  328. ;======================================================================
  329.  
  330.     SECTION    "b",BSS
  331.  
  332. _buf_200    ds.b    $200
  333.  
  334. ;======================================================================
  335.  
  336.     END
  337.  
  338.